package com.example.ly.myapplication;

import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Environment;
import android.os.IBinder;

public class MusicService extends Service {
    private MediaPlayer player;
    private String mp3Path ="";
    private boolean isPause = false;
    public MusicService() {
    }

    @Override
    public void onCreate() {
        super.onCreate();
        mp3Path= Environment.getExternalStorageDirectory().getAbsolutePath()+"/mp3/";
        player= new MediaPlayer();
    }

    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.
        throw new UnsupportedOperationException("Not yet implemented");
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        String action = intent.getStringExtra("action");
        switch (action){
//            case "play":play();
            case "pause":pause();
        }
        return super.onStartCommand(intent, flags, startId);
    }
    private void play() throws Exception{

    }
    private void pause(){
        player.pause();
        isPause=true;
    }
}
